import "package:ct_pa_majordomo/config/theme_vars.dart";
import "package:ct_pa_majordomo/pages/apartment/unlock_permission/add_permission/index.dart";
import "package:ct_pa_majordomo/pages/apartment/unlock_permission/permission_list/index.dart";
import "package:ct_pa_majordomo/pages/widgets/menu_block.dart";
import "package:ct_pa_majordomo/router/keys.dart";
import "package:ct_pa_majordomo/utils/stacker.dart";
import "package:ct_pa_majordomo/widgets/normal_scaffold/index.dart";
import "package:flutter/cupertino.dart";
import "package:flutter/material.dart";

class UnlockPermission extends StatefulWidget {
  final Map roomInfo;
  const UnlockPermission({super.key, required this.roomInfo});

  @override
  State<StatefulWidget> createState() => _UnlockPermissionState();

}

class _UnlockPermissionState extends State<UnlockPermission> {


  Widget _roundBtn({Widget? child}) {
    return Container(
      padding: EdgeInsets.all(6),
      decoration: BoxDecoration(
        color: ThemeVars.colorPrimary,
        borderRadius: BorderRadius.circular(50),
        boxShadow: [BoxShadow(color: ThemeVars.colorPrimaryLight, spreadRadius: 5, blurRadius: 12)]
      ),
      child: child ?? Icon(Icons.arrow_forward_ios, color: Colors.white, size: 18,),
    );
  }

  @override
  Widget build(BuildContext context) {
    return NormalScaffold(
      title: "开门权限",
      // actions: [
      //   TextButton(
      //     onPressed: () {
      //       print("管理");
      //     },
      //     child: Text("管理", style: TextStyle(color: Colors.white),)
      //   )
      // ],
      child: Container(
        padding: EdgeInsets.all(ThemeVars.paddingPage),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Stack(
              children: [
                MenuBlock(
                  items: [
                    MenuBlockItem(
                      text: "",
                      showArrow: false,
                      onTap: () {
                        Stacker.pushNamed(Keys.APARTMENT_UNLOCK_PERMISSION_SEND_KEY, arguments: {"roomId": widget.roomInfo["roomId"], "renter": widget.roomInfo["renterList"]});
                      },
                      prefix: Row(
                        children: [
                          Container(
                            padding: EdgeInsets.all(6),
                            decoration: BoxDecoration(
                              color: ThemeVars.colorPrimary,
                              borderRadius: BorderRadius.all(Radius.circular(100)),
                            ),
                            child: Icon(Icons.key, color: Colors.white,),
                          ),
                          SizedBox(width: 12,),
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text("发送钥匙", style: TextStyle(fontSize: 20, color: ThemeVars.colorPrimary, fontWeight: FontWeight.w500),),
                              Text("(租客微信开门)")
                            ],
                          )
                        ],
                      ),
                      suffix: _roundBtn(
                        child: Padding(
                          padding: EdgeInsets.symmetric(horizontal: 12),
                          child: Text("发送", style: TextStyle(color: Colors.white),),
                        )
                      )
                    )
                  ],
                ),
                Positioned(
                  right: 0,
                  top: 0,
                  child: Container(
                    width: 50,
                    height: 18,
                    alignment: Alignment.center,
                    decoration: const BoxDecoration(
                      borderRadius: BorderRadius.only(topRight: Radius.circular(8), bottomLeft: Radius.circular(15)),
                      color: Colors.orange,
                    ),
                    child: const Text("推荐", style: TextStyle(fontSize: 12, color: Colors.white),),
                  ),
                )
              ],
            ),
            const SizedBox(height: 12,),
            MenuBlock(
              items: [
                MenuBlockItem(
                  text: "获取密码",
                  showArrow: false,
                  prefix: Container(
                    padding: EdgeInsets.all(6),
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.all(Radius.circular(100)),
                        border: Border.all(color: ThemeVars.colorPrimaryLight, width: 2)
                    ),
                    child: Icon(Icons.calendar_view_month, color: ThemeVars.colorPrimary,),
                  ),
                  suffix: _roundBtn(),
                  onTap: () {
                    Stacker.pushNamed(Keys.APARTMENT_UNLOCK_PERMISSION_GET_PWD_KEY, arguments: {"roomId": widget.roomInfo["roomId"], "renter": widget.roomInfo["renterList"]},);
                  }
                ),
              ]
            ),
            // const SizedBox(height: 12,),
            // MenuBlock(
            //     items: [
            //       MenuBlockItem(
            //           text: "添加IC卡",
            //           showArrow: false,
            //           prefix: Container(
            //             padding: EdgeInsets.all(6),
            //             decoration: BoxDecoration(
            //                 borderRadius: BorderRadius.all(Radius.circular(100)),
            //                 border: Border.all(color: ThemeVars.colorPrimaryLight, width: 2)
            //             ),
            //             child: Icon(Icons.calendar_view_month, color: ThemeVars.colorPrimary,),
            //           ),
            //           suffix: _roundBtn(),
            //           onTap: () {
            //             Stacker.pushNamed(Keys.APARTMENT_UNLOCK_PERMISSION_LIST, arguments: PermissionType.icCard,);
            //           }
            //       ),
            //     ]
            // ),
            const SizedBox(height: 12,),
            MenuBlock(
              items: [
                MenuBlockItem(
                    text: "添加指纹",
                    showArrow: false,
                    prefix: Container(
                      padding: EdgeInsets.all(6),
                      decoration: BoxDecoration(
                          borderRadius: BorderRadius.all(Radius.circular(100)),
                          border: Border.all(color: ThemeVars.colorPrimaryLight, width: 2)
                      ),
                      child: Icon(Icons.fingerprint, color: ThemeVars.colorPrimary,),
                    ),
                    suffix: _roundBtn(),
                    onTap: () {
                      Stacker.pushNamed(Keys.APARTMENT_UNLOCK_PERMISSION_LIST, arguments: {"type": PermissionType.fingerprint, "roomId": widget.roomInfo["roomId"], "renter": widget.roomInfo["renterList"]}, );
                    }
                )
              ]
            )
          ],
        ),
      ),
    );
  }

}